package com.pbc.gmp.service.impl;

import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import com.pbc.gmp.dao.LeftMenuTreeMapper;
import com.pbc.gmp.model.LeftMenuDto;
import com.pbc.gmp.model.MenuTreeResourseDto;
import com.pbc.gmp.model.basemodel.MenuRes;
import com.pbc.gmp.dao.MenuResMapper;
import com.pbc.gmp.service.IMenuResService;

import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.HashSet;
import java.util.List;
import java.util.Set;

/**
 * <p>
 *   服务实现类
 * </p>
 *
 * @author kjk
 * @since 2017-04-17
 */
@Service
public class MenuResServiceImpl extends ServiceImpl<MenuResMapper, MenuRes> implements IMenuResService {

    @Resource(name="MenuResDao")
    private MenuResMapper menuResMapper;

    @Override
    public List<MenuTreeResourseDto> selectAllLeftMenuByRoleId(Long id) {

        return  menuResMapper.selectAllLeftMenuByRoleId(id);
    }

    @Override
    public List<MenuTreeResourseDto> selectAllLeftMenu() {
        return menuResMapper.selectAllLeftMenu();
    }

    @Override
    public List<MenuTreeResourseDto> selectAllRes() {
        return menuResMapper.selectAllRes();
    }

    public Set<MenuTreeResourseDto> selectAllLeftMenuByRoleIds(Set<Long> ids){
        Set<MenuTreeResourseDto> menus=new HashSet<MenuTreeResourseDto>();
        for (Long id :ids)
        {
            menus.addAll(this.selectAllLeftMenuByRoleId(id));
        }
        return menus;

    }
}
